package com.java.controller;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import com.java.entity.SuggestInfo;
import com.java.service.SuggestService;
import com.java.util.resp.BaseRespone;
import com.java.util.resp.TableRespone;

@RestController
public class SuggestController {
	@Autowired
	private SuggestService suggestService;

	@PostMapping("/getSuggests")
	public TableRespone getSuggests(@RequestParam(required = false, defaultValue = "0") int page,
			@RequestParam(required = false, defaultValue = "0") int size) {
		return suggestService.getSuggestList(page, size);
	}

	@PostMapping("/saveSuggest")
	public BaseRespone saveSuggest(@RequestBody SuggestInfo suggestInfo) {
		return suggestService.saveSuggest(suggestInfo.getSuggestId(), suggestInfo.getSuggestText(),
				suggestInfo.getSuggestShow());
	}

	@PostMapping("/delSuggest")
	public BaseRespone delSuggest(@RequestParam(required = false) String suggestId) {
		return suggestService.delSuggest(suggestId);
	}

}
